﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="H2.NET.Web.BI.Template.Index" %>

<%@ Register src="../../UserControls/Pager.ascx" tagname="Pager" tagprefix="uc1" %>
<%@ Register src="../../UserControls/Toolbar.ascx" tagname="Toolbar" tagprefix="uc1" %>

<form id="pagerForm" onsubmit="return navTabSearch(this);" action="<%= Request.RawUrl %>"
method="post">
    <input type="hidden" name="pageNum" value="<%= PageNumber %>" />
    <input type="hidden" name="numPerPage" value="<%= PageSize %>" />
<div class="pageHeader">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    <label>
                        模版名称：</label><input type="text" name="name" id="name" size="30" value="<%= name %>" />
                </td>
            </tr>
        </table>
        <div class="subBar">
            <span class="info_clear">符合条件的记录，共有 <strong>
                <%= TotalItemCount %></strong>条。</span>
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                检索</button></div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="reset">
                                重置</button></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
</form>
<form id="form1" runat="server">
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <uc1:Toolbar ID="Toolbar1" runat="server" />
        </ul>
    </div>
    <table class="table" width="60%" layouth="137">
        <thead>
            <tr>
                <th style="width: 5%;">
                    序号
                </th>
                <th align="center" style="width: 25%;">
                    模版名称
                </th>
                <th align="center" style="width: 25%;">
                    创建人
                </th>
                <th align="center" style="width: 25%;">
                    创建时间
                </th>
            </tr>
        </thead>
        <tbody>
            <%
                int i = 1;
                foreach (var t in templates)
                {%>
                    <tr rel='<%:t.id%>' target="selectedId">
                        <td class="fixedcol"><%:i%></td>
                        <td><%:t.name%></td>
                        <td><%:t.create_user%></td>
                        <td><%:t.create_date%></td>
                    </tr> 
                <%
                    i++;
                }    
             %>
        </tbody>
    </table>
</div>
<uc1:Pager ID="Pager1" runat="server" />
</form>
<script type="text/javascript">
    function TemplateExec(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        navTab.openTab(rel, url + "?mid=46", { title: title, data: { id:id } });
        return false;
    }

    function TemplateEdit(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        navTab.openTab(rel, url + "?mid=48", { title: title, data: { id: id } });
        return false;
    }

    function TemplateCopy(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        navTab.openTab(rel, url + "?mid=48&&cp=1", { title: title, data: { id: id } });
        return false;
    }

    function TemplateDelete(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        alertMsg.confirm(title, {
            okCall: function () {
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: { id: id, title: title },
                    dataType: "json",
                    cache: false,
                    success: function (json) {
                        DWZ.ajaxDone(json);
                        var $rpt = $("a[rpt=" + id + "]");
                        if($rpt){
                            $rpt.parent().remove();
                        }
                        navTabSearch($("#pagerForm", navTab.getCurrentPanel()));
                    },
                    error: DWZ.ajaxError
                });
            }
        });
        return false;
    }
</script>